package cuiyt.datastructure.queue.dequeue;


import cuiyt.datastructure.common.List;
import cuiyt.datastructure.linkedlist.sigle.CyLinkedList;

/**
 * @author cyt
 * @create 2020-12-05 17:57
 */
public class DeQueue<E> {
    private List<E> list = new CyLinkedList<>();

    public E deDeQueueFront() {
        return list.remove(0);
    }

    public E deDeQueueRear() {
        return list.remove(list.size() - 1);
    }

    public void enDeQueueFront(E element) {
        list.add(0, element);
    }

    public void enDeQueueRear(E element) {
        list.add(element);
    }

    public int size() {
        return list.size();
    }

    public boolean isEmpty() {
        return list.isEmpty();
    }

    public E rear() {
        return list.get(list.size() - 1);
    }

    public E front() {
        return list.get(0);
    }

}
